package cn.gson.crmdemo.common;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@SuppressWarnings("deprecation")
@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter  implements WebMvcConfigurer{
	@Configuration
	public class MyConfiguration {

	    @SuppressWarnings("deprecation")
		@Bean
	    public WebMvcConfigurer corsConfigurer() {
	        return new WebMvcConfigurerAdapter() {
	            @Override
	            public void addCorsMappings(CorsRegistry registry) {
	                registry.addMapping("/**");
	            }
	        };
	    }
	}
	
	
		// 这个方法是用来配置静态资源的，比如html，js，css，等等
		  @Override
		  public void addResourceHandlers(ResourceHandlerRegistry registry) {
		  }
		 
		  // 这个方法用来注册拦截器，我们自己写好的拦截器需要通过这里添加注册才能生效
		 
		  @Override
		    public void addFormatters(FormatterRegistry registry) {
		       registry.addConverter(new DateConverter());
		    }
		
}
